<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Align Example</title>
    <style>
        /* 使用 align-items 进行垂直对齐 */
        .flex-container {
            display: flex;
            height: 200px;
            align-items: center; /* 子元素在垂直方向居中 */
            background-color: lightgray;
        }

        /* 使用 align-content 进行多行对齐 */
        .multi-line {
            display: flex;
            flex-wrap: wrap;
            align-content: center; /* 多行内容均匀分布 */
            height: 200px;
            background-color: black;
            cursor: pointer;
        }

        /* 使用 text-align 进行文本水平对齐 */
        p {
            text-align: center; /* 文本在段落内水平居中 */
        }
        @media screen and (max-width: 600px) {
            .multi-line {
                background-color: aqua;
            }
        }
    </style>
</head>
<body>
<div class="flex-container">
    <div style="width: 100px; height: 100px; background: red;">Item 1</div>
    <div style="width: 100px; height: 100px; background: blue;">Item 2</div>
    <div style="width: 100px; height: 100px; background: green;">Item 3</div>
    <div style="width: 100px; height: 100px; background: yellow;">Item 4</div>
</div>

<div class="multi-line">
    <div style="width: 100px; height: 100px; background: red;">Item 1</div>
    <div style="width: 100px; height: 100px; background: blue;">Item 2</div>
    <div style="width: 100px; height: 100px; background: green;">Item 3</div>
    <div style="width: 100px; height: 100px; background: yellow;">Item 4</div>
</div>
<p>这是一个居中对齐的段落。</p>
</body>
</html>